﻿using BySoft.Server.Business;
using BySoft.Server.Common;
using BySoft.Server.Common.Entity;
using BySoft.Web.Utility;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace BySoft.Web.Site.MasteData
{
    public partial class MaterialSmallTypeView : AuthBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ddlPartType.Attributes.Add("readonly", "true");
            
                InitDDL();
                BindData();
            }
        }
        void InitDDL()
        {

            DataTable dt = MdMaterialtype.GetMdMaterialtypeAll().Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                this.ddlPartType.DataSource = dt;
                this.ddlPartType.DataTextField = "MaterialTypeName";
                this.ddlPartType.DataValueField = "MaterialTypeID";
                this.ddlPartType.DataBind();
            }

           
            UIHelper.InsertFirstItem(ddlPartType);

            //BindParameterForDDL("ModuleType", ddlPartType);

            //UIHelper.InsertFirstItem(ddlPartType);
        }

        private void BindData()
        {
            string strCode = HttpUtility.UrlDecode(UIHelper.GetQueryStringValue("id").Trim());
            if (!string.IsNullOrEmpty(strCode))
            {
                MdMaterialsmalltypeEntity en = MdMaterialsmalltype.GetMdMaterialsmalltypeByID(strCode);
                if (en != null)
                {
                    this.lblMaterialSmallTypeID.Text = en.MaterialSmallTypeID;
                    this.lblMaterialSmallTypeName.Text = en.MaterialSmallTypeName;
                    //this.chkIsHalfFinished.Checked = en.IsHalfFinished.Equals("1") ? true : false;
                    this.ddlPartType.SelectedValue = en.MaterialTypeID;
                 

                   
                }
            }
        }
    }
}